#include "Buffer.h"
#include <memory>
#include <cstring>
#include "MemCacheTemplateSingleton.h"



Buffer::Buffer()
	:m_Buffer{ 0 }
{
	m_Length = 0;
}
Buffer::~Buffer()
{
}
Buffer* Buffer::Allocate()
{
	auto buffer = ::Allocate<Buffer>();
	memset(buffer->m_Buffer, 0, sizeof(m_Buffer));
	buffer->m_Length = 0;
	return buffer;
}
void Buffer::Free()
{
	::Free(this);
}
void Buffer::Append(const void* data, int len)
{
	std::memcpy(m_Buffer + m_Length, data, len);
	m_Length += len;
}
const char* Buffer::GetData()
{
	return m_Buffer;
}
int Buffer::Length()
{
	return m_Length;
}
int Buffer::Available()
{
	return LOG_BUFFER_SIZE - m_Length;
}
void Buffer::Reset()
{
	m_Length = 0;
}